//
//  TWVideoCollectionOfFollowCell.swift
//  EyepetizerImitative
//
//  Created by 田伟 on 2017/3/30.
//  Copyright © 2017年 个人. All rights reserved.
//

import UIKit

class TWVideoCollectionOfFollowCell: UITableViewCell {

    
    @IBOutlet weak var bigImageView: UIImageView!
    @IBOutlet weak var detailCollectionView: TWDetailCollectionView!
    @IBOutlet weak var titleView: UIView!
    @IBOutlet weak var titleLabel: UILabel!
    @IBOutlet weak var discributionLabel: UILabel!
    @IBOutlet weak var iconView: UIView!
    @IBOutlet weak var iconbottom: UIImageView!
    @IBOutlet weak var iconMiddel: UIImageView!
    @IBOutlet weak var iconTop: UIImageView!
    
    // MARK:- 自定义属性
    var videoCollectionOfFollowModel : TWVideoCollectionOfFollowModel?{
        didSet {
            guard let videoCollectionOfFollowModel = videoCollectionOfFollowModel else {
                return
            }
            
            let urlString = videoCollectionOfFollowModel.header?.cover
            guard let urlStr = urlString else {
                return
            }
            // 设置大图控件
            bigImageView.sd_setImage(with: URL(string: urlStr))
            titleLabel.text = videoCollectionOfFollowModel.header?.title
            discributionLabel.text = videoCollectionOfFollowModel.header?.tw_description
            // 设置detailCollectionView的内容
            detailCollectionView.videosArray = videoCollectionOfFollowModel.itemList_tw
            // 设置头像
            let iconArray = videoCollectionOfFollowModel.header?.iconList
            guard let iconArr = iconArray else {
                return
            }
            if iconArr.count >= 3 {
                iconTop.setImageWith(URL(string: iconArr.last!)!)
                iconMiddel.setImageWith(URL(string: iconArr[1])!)
                iconbottom.setImageWith(URL(string: iconArr.first!)!)
            }
        }
    }
    override func awakeFromNib() {
        super.awakeFromNib()
        let tap = UITapGestureRecognizer(target: self, action: #selector(bigImageViewDidTap(tap:)))
        bigImageView.addGestureRecognizer(tap)
    }
    
    @objc fileprivate func bigImageViewDidTap(tap : UITapGestureRecognizer){
        print((videoCollectionOfFollowModel?.header?.actionUrl)! as String)
    }


    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        // Configure the view for the selected state
    }
    
}
